WPS Office.apk(点击下载) / ptx.java


package defpackage;

import android.text.TextUtils;
import cn.wps.moffice.OfficeApp;
import cn.wps.moffice_eng.R;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.iflytek.cloud.SpeechEvent;
import com.iflytek.cloud.SpeechUtility;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/* renamed from: ptx  reason: default package */
public final class ptx {
    private static String rIZ = (OfficeApp.arx().arM().lZT + File.separator + ".letters");
    private static String rJa = (OfficeApp.arx().arM().lZT + File.separator + ".mine_");
    private static Pattern rJb = Pattern.compile("[0-9]+\\.jpg");

    public static pug[] NV(String str) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        return (pug[]) lvb.readObject(rJa + str, pug[].class);
    }

    public static boolean NW(String str) {
        String asP = cqy.asP();
        return TextUtils.isEmpty(str) ? !TextUtils.isEmpty(asP) : !str.equals(asP);
    }

    public static boolean NX(String str) {
        return rJb.matcher(str).matches();
    }

    public static boolean YU(int i) {
        boolean z = true;
        String a = lwv.a("https://docer.wps.cn/v3.php/api/android/background/v1/buy_info?id=%d", Integer.valueOf(i));
        try {
            HashMap hashMap = new HashMap();
            hashMap.put("cookie", "wps_sid=" + cqy.asP());
            JSONObject jSONObject = new JSONObject(lwd.f(a, hashMap));
            String string = jSONObject.getString(SpeechUtility.TAG_RESOURCE_RESULT);
            JSONObject jSONObject2 = jSONObject.getJSONObject(SpeechEvent.KEY_EVENT_RECORD_DATA);
            if (!string.equals("ok")) {
                return false;
            }
            boolean z2 = (jSONObject2.optInt("is_buy") == 1) | false;
            if (jSONObject2.optInt("is_docer_vip") != 1) {
                z = false;
            }
            return z2 | z;
        } catch (JSONException e) {
            new StringBuilder("getLetterBgBuyingState: ").append(e.toString());
            return false;
        } catch (IOException e2) {
            new StringBuilder("getLetterBgBuyingState: ").append(e2.toString());
            return false;
        } catch (Exception e3) {
            new StringBuilder("getLetterBgBuyingState: ").append(e3.toString());
            return false;
        }
    }

    public static String YV(int i) {
        String str = "https://docer.wps.cn/v3.php/api/android/background/v1/download?id=" + i;
        try {
            HashMap hashMap = new HashMap();
            hashMap.put("cookie", "wps_sid=" + cqy.asP());
            JSONObject jSONObject = new JSONObject(lwd.f(str, hashMap));
            return jSONObject.getString(SpeechUtility.TAG_RESOURCE_RESULT).equals("ok") ? jSONObject.getJSONObject(SpeechEvent.KEY_EVENT_RECORD_DATA).optString("mb_url") : "";
        } catch (JSONException e) {
            new StringBuilder("getMineLetterDownloadUrl: ").append(e.toString());
            return "";
        } catch (IOException e2) {
            new StringBuilder("getMineLetterDownloadUrl: ").append(e2.toString());
            return "";
        } catch (Exception e3) {
            new StringBuilder("getMineLetterDownloadUrl: ").append(e3.toString());
            return "";
        }
    }

    public static boolean a(pug pug) {
        if (pug == null) {
            return false;
        }
        return new File(pug.rJo + pug.getId() + ".jpg").exists();
    }

    public static void dm(List<pug> list) {
        lvb.writeObject(list, rIZ);
    }

    public static boolean eAW() {
        return gqt.bTm();
    }

    public static pug[] eAX() {
        return (pug[]) lvb.readObject(rIZ, pug[].class);
    }

    public static List<pug> eAY() {
        ArrayList arrayList = new ArrayList();
        try {
            HashMap hashMap = new HashMap();
            hashMap.put("cookie", "wps_sid=" + cqy.asP());
            OfficeApp arx = OfficeApp.arx();
            JSONObject jSONObject = new JSONObject(lwd.f(String.format("https://docer.wps.cn/v3.php/api/android/background/v1/data?page=1&page_size=50&package=%s&version=%s&firstchannel=%s&channel=%s&lang=%s", arx.getPackageName(), arx.getString(R.string.app_version), arx.arA(), arx.arB(), eip.dHN), hashMap));
            String string = jSONObject.getString(SpeechUtility.TAG_RESOURCE_RESULT);
            JSONObject jSONObject2 = jSONObject.getJSONObject(SpeechEvent.KEY_EVENT_RECORD_DATA);
            if (!string.equals("ok")) {
                return arrayList;
            }
            if (jSONObject2.optInt("total_num") == 0) {
                return arrayList;
            }
            JSONArray optJSONArray = jSONObject2.optJSONArray(SpeechEvent.KEY_EVENT_RECORD_DATA);
            if (optJSONArray == null) {
                return arrayList;
            }
            int length = optJSONArray.length();
            for (int i = 0; i < length; i++) {
                JSONObject jSONObject3 = optJSONArray.getJSONObject(i);
                pug pug = new pug(3, jSONObject3.optInt("id"), jSONObject3.optString("name"), jSONObject3.optInt(FirebaseAnalytics.Param.PRICE), jSONObject3.optString("thumb_small_url"), jSONObject3.optString("thumb_medium_url"), jSONObject3.optString("thumb_big_url"));
                pug.rJw = pug.rJu != 0;
                arrayList.add(pug);
            }
            return arrayList;
        } catch (JSONException e) {
            new StringBuilder("getRecommendLetterBg: ").append(e.toString());
            return arrayList;
        } catch (IOException e2) {
            new StringBuilder("getRecommendLetterBg: ").append(e2.toString());
            return arrayList;
        } catch (Exception e3) {
            new StringBuilder("getRecommendLetterBg: ").append(e3.toString());
            return arrayList;
        }
    }

    public static List<pug> eAZ() {
        ArrayList arrayList = new ArrayList();
        String a = lwv.a("https://docer.wps.cn/v3.php/api/android/background/v1/my_buy_mbs?page=%s&page_size=%s", 1, 50);
        try {
            HashMap hashMap = new HashMap();
            hashMap.put("cookie", "wps_sid=" + cqy.asP());
            JSONObject jSONObject = new JSONObject(lwd.f(a, hashMap));
            String string = jSONObject.getString(SpeechUtility.TAG_RESOURCE_RESULT);
            JSONObject jSONObject2 = jSONObject.getJSONObject(SpeechEvent.KEY_EVENT_RECORD_DATA);
            if (!string.equals("ok")) {
                return arrayList;
            }
            int optInt = jSONObject2.optInt("total");
            if (optInt == 0) {
                return arrayList;
            }
            JSONArray optJSONArray = jSONObject2.optJSONArray(SpeechEvent.KEY_EVENT_RECORD_DATA);
            if (optJSONArray == null) {
                return arrayList;
            }
            int length = optJSONArray.length();
            for (int i = 0; i < length; i++) {
                JSONObject jSONObject3 = optJSONArray.getJSONObject(i);
                pug pug = new pug(3, jSONObject3.optInt("id"), jSONObject3.optString("name"), jSONObject3.optInt("buy_price"), jSONObject3.optString("thumb_small_url"), jSONObject3.optString("thumb_medium_url"), jSONObject3.optString("thumb_big_url"));
                pug.rJv = jSONObject3.optLong("buy_time");
                arrayList.add(pug);
            }
            if (optInt > 50) {
                int i2 = optInt / 50;
                int i3 = optInt % 50;
                for (int i4 = 1; i4 <= i2; i4++) {
                    List<pug> iu = iu(i4, 50);
                    if (!iu.isEmpty()) {
                        arrayList.addAll(iu);
                    }
                }
            }
            return arrayList;
        } catch (JSONException e) {
            new StringBuilder("getMineLetterBg: ").append(e.toString());
            return arrayList;
        } catch (IOException e2) {
            new StringBuilder("getMineLetterBg: ").append(e2.toString());
            return arrayList;
        } catch (Exception e3) {
            new StringBuilder("getMineLetterBg: ").append(e3.toString());
            return arrayList;
        }
    }

    private static List<pug> iu(int i, int i2) {
        ArrayList arrayList = new ArrayList();
        String a = lwv.a("https://docer.wps.cn/v3.php/api/android/background/v1/my_buy_mbs?page=%s&page_size=%s", Integer.valueOf(i), 50);
        try {
            HashMap hashMap = new HashMap();
            hashMap.put("cookie", "wps_sid=" + cqy.asP());
            JSONObject jSONObject = new JSONObject(lwd.f(a, hashMap));
            String string = jSONObject.getString(SpeechUtility.TAG_RESOURCE_RESULT);
            JSONObject jSONObject2 = jSONObject.getJSONObject(SpeechEvent.KEY_EVENT_RECORD_DATA);
            if (!string.equals("ok")) {
                return arrayList;
            }
            if (jSONObject2.optInt("total_num") == 0) {
                return arrayList;
            }
            JSONArray optJSONArray = jSONObject2.optJSONArray(SpeechEvent.KEY_EVENT_RECORD_DATA);
            if (optJSONArray == null) {
                return arrayList;
            }
            int length = optJSONArray.length();
            for (int i3 = 0; i3 < length; i3++) {
                JSONObject jSONObject3 = optJSONArray.getJSONObject(i3);
                pug pug = new pug(3, jSONObject3.optInt("id"), jSONObject3.optString("name"), jSONObject3.optInt("buy_price"), jSONObject3.optString("thumb_small_url"), jSONObject3.optString("thumb_medium_url"), jSONObject3.optString("thumb_big_url"));
                pug.rJv = jSONObject3.optLong("buy_time");
                arrayList.add(pug);
            }
            return arrayList;
        } catch (JSONException e) {
            new StringBuilder("getMineLetterBg: ").append(e.toString());
            return arrayList;
        } catch (IOException e2) {
            new StringBuilder("getMineLetterBg: ").append(e2.toString());
            return arrayList;
        } catch (Exception e3) {
            new StringBuilder("getMineLetterBg: ").append(e3.toString());
            return arrayList;
        }
    }

    public static void t(String str, List<pug> list) {
        if (!TextUtils.isEmpty(str)) {
            lvb.writeObject(list, rJa + str);
        }
    }
}